package com.example.taximeter.mapper;

import com.example.taximeter.bean.Company;
import com.example.taximeter.bean.Fact;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 出租车公司
 */
@Mapper
public interface CompanyMapper {

    //查询出租车公司列表
    @Select("select id , company_name from tab_dict_taxi_company")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "companyname", column = "company_name"),
    })
    List<Company> findCompanyList();

    //查询出租车公司(出租车公司名称)
    @Select("select id , company_name from tab_dict_taxi_company where company_name = #{companyname,jdbcType=VARCHAR} ")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "companyname", column = "company_name")
    })
    List<Company> findCompanyByCompanyname(@Param("companyname") String companyname);

    //查询出租车公司(id)
    @Select("select id , company_name from tab_dict_taxi_company where id = #{id,jdbcType=INTEGER} ")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "companyname", column = "company_name")
    })
    Company findCompanyById(Integer id);

    //新增出租车公司
    @Insert("insert into tab_dict_taxi_company (company_name,memo)\n" +
            "    values (#{companyname,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}) ")
    Boolean addCompany(Company company);

    //修改出租车公司
    @Update("update tab_dict_taxi_company set company_name = #{companyname,jdbcType=VARCHAR},memo = #{memo,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER}")
    boolean updateCompany(Company company);


    //删除出租车公司
    @Delete("delete from tab_dict_taxi_company  where id = #{id,jdbcType=INTEGER}")
    boolean deleteCompany(Integer id);

    //查询出租车公司列表
    @SelectProvider(type = ActivityMapperProvider.class, method = "findCompanyAll")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "companyname", column = "company_name"),
            @Result(property = "memo", column = "memo")

    })
    List<Company> findCompanyAll(Company company);

}
